﻿
using System;
namespace DotNetNeural.Metrics
{
    public class DefaultMetric : IMetric
    {
        #region IMetric Members

        public float CalculateDistance(float[] lhs, float[] rhs)
        {
            if (lhs == null || rhs == null)
                throw new NullReferenceException("Illegal null-reference args");

            if (lhs.Length != rhs.Length)
                throw new ArgumentException("Both items should have the same dimensions");

            float sum = 0;

            for (int i = 0; i < lhs.Length; ++i)
            {
                sum += (lhs[i] - rhs[i]) * (lhs[i] - rhs[i]);
            }

            return (float)Math.Sqrt(sum);
        }

        #endregion
    }
}
